<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script language="JavaScript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script type="text/javascript">
   var houseValidateId = null;
   function openHouseValidateAdd(){
        var url = "${ctx}/occupation_joinHandleAction.do?method=checkAllowHouseValidate&houseIds=${houseIds}&optType=add&identityValidateId=${id}";
		new Ajax.Request(url,{method: 'post' ,onSuccess : function(response){
			ajaxSubmitException(response.responseText);
			if(response.responseText == 'false'){
				Alert('已经存在验房通过记录！');
			}else if(response.responseText == "noMeter"){
				 AlarmConfirm('该房间的房产资料中未初始化走表信息，是否继续?',"houseValidate","showAddHouseValidate");
			}else{
				showAddHouseValidate();
			}
		}});
   }
   function showAddHouseValidate(){
   		var url = "${ctx}/occupation_joinHandleAction.do?method=initHouseValidateBaseMain&id=${id}&optType=add";
		top.windowOpen(url, 'HouseValidateAdd', '', 520, 800, true, "HouseValidateAdd");
   }
   function openHouseValidateEdit(){
        if(houseValidateId == null){
			ErrorAlert("${key.tipsByModify}");
			return false;
		}
		else{
		    var url = "${ctx}/occupation_joinHandleAction.do?method=checkAllowHouseValidate&optType=edit&identityValidateId=${id}&inspecteRequisiteId="+houseValidateId;
			new Ajax.Request(url,{method: 'post' ,onSuccess : function(response){
				if(response.responseText == '-1'){
					Alert('已经存在验房通过记录不允许修改！');
				}else if(response.responseText == '-2'){
					Alert('存在已派工的整改项目,不允许修改！');
				}
				else{
				var url = "${ctx}/occupation_joinHandleAction.do?method=initHouseValidateBaseMain&id=${id}&optType=edit&keyword="+houseValidateId;
			    top.windowOpen(url, 'HouseValidateEdit', '', 520, 800, true, "HouseValidateEdit");
				}
			}});

		}

   }
   function showHouseValidateDelete(){
		if( houseValidateId == null ){
			ErrorAlert('${key.tipsByDelete}');
		}else{
		    var url = "${ctx}/occupation_joinHandleAction.do?method=checkAllowHouseValidate&optType=delete&identityValidateId=${id}&inspecteRequisiteId="+houseValidateId;
			new Ajax.Request(url,{method: 'post' ,onSuccess : function(response){
			    ajaxSubmitException(response.responseText);
				if(response.responseText == '-1'){
					Alert('已经存在验房通过记录不允许删除！');
				}
				else if(response.responseText == '-2'){
					Alert('存在已派工或已完工的记录不允许删除！');
				}
				else{
				  AlarmConfirm('${key.tipsByDeleteConfirm}',"houseValidate","deleteHouseValidate");
				}
			}});

		}
	}
	function deleteHouseValidate(){
		var url="${ctx}/occupation_joinHandleAction.do?method=deleteHouseValidate";
		var param = "keyword="+houseValidateId;
		var myAjax = new Ajax.Request(
	                   url,
	                   {method: 'post', parameters:param , onComplete: showResponseDelete}
	                   );
	}
	function showResponseDelete(transport){
		ajaxSubmitException(transport.responseText);
		if(transport.responseText=="false"){
			FailureAlert('${key.doFalse}');
		}else{
			reloadHouseValidateList();
		}
	}
   function showDetail(keyword){
   		var url = "${ctx}/occupation_joinHandleAction.do?method=getHouseValidateDetail&identityId=${id}&id="+keyword;
		top.windowOpen(url, 'cc', '详细', 520, 800, true, "cc");
   }
   function setInspecteRequisiteId(id){
   		houseValidateId = id;
   }
   function reloadHouseValidateList(){
   		houseValidateId = null;
   		$('houseValidateList').src="${ctx}/occupation_joinHandleAction.do?method=initHouseValidateList&id=${id }";
   }
</script>
</head>
<body>
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab_line">
                        <tr>
                          <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" >
                              <tr>
                                <td class="bg_toolBar"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="35%" align="right"><table border="0" cellpadding="0" cellspacing="0" id="ico1">
                                        <tr>
                                          <td class="toolbarico"><a href="#"  onClick="openHouseValidateAdd()" onFocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="新建申请" /></a></td>
                                          <td class="toolbarico"><a href="#"  onClick="openHouseValidateEdit()" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="修改申请" /></a></td>
                                          <td class="toolbarico"><a href="#" onClick="showHouseValidateDelete()" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="删 除" width="16" height="16" border="0" align="absbottom" /></a></td>
                                          <td  class="toolbarico">&nbsp;</td>
                                        </tr>
                                      </table></td>
                                    </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td colspan="5" >
                                <iframe src="${ctx}/occupation_joinHandleAction.do?method=initHouseValidateList&id=${id }" name="houseValidateList" id="houseValidateList" width="100%" height="300px" frameborder="0" scrolling="auto"> </iframe>
                                </td>
                              </tr>
                          </table></td>
                        </tr>
            </table>
</body>
</html>